<template>
	<view class="content">
		<view class="wrap" v-for="(item, index) in articleIndexData" :key="index">
			<view class="title_wrap">
				<view>{{item.articlesTypeName}}</view>
				<view @tap="toArticleListPage(item.articlesTypeId)">查看更多 ></view>
			</view>
			<view class="article_wrap">
				<view class="article_item" v-for="(data, index) in item.articlesDtoList" :key="index" @click="goToArticleDetail(data.id)">
					<view class="article_content">
						<view class="article_image">
							<image :src="data.imgUrl"
								mode="widthFix" style="max-width: 320rpx;max-height: 320rpx;heborder-radius: 20rpx;margin-top: 10rpx;">
							</image>
						</view>
						<view class="article_title" style="color: #999999;">{{data.title}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: ['articleIndexData'],
		onLoad() {

		},
		methods: {
			// 跳转搜索页面
			toArticleListPage(articlesTypeId) {
				uni.navigateTo({
					url: '/pages/article/article-list?articlesTypeId='+articlesTypeId
				});
			},
			goToArticleDetail(id) {
				uni.navigateTo({
					url: '/pages/article/article-detail?id=' + id
				});
			}
		},
	}
</script>

<style scoped lang="scss">
	page {
		background-color: white;
	}
	.wrap {
		// 这个只是让整体在页面居中展示
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		height: 100%;
		padding: 8px;
		background-color: white;
	}

	.title_wrap {
		display: flex;
		width: 94%;
		flex-direction: row;
		justify-content: space-between;
		margin-top: 8rpx;
		margin-bottom: 8rpx;
	}

	.article_wrap {
		// 卡片容器
		display: flex;
		flex-wrap: wrap;
		width: 100%;
	}

	.article_item {
		// 每个卡片
		flex-basis: 50%;
		padding: 0px 8px;
		margin-bottom: 8px;
		box-sizing: border-box;
	}

	.article_content {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		// 卡片内容
		// background-color: white;
		// border-radius: 10px;
		height: 100%;
		width: 100%;
	}

	.article_image {
		text-align: center;
	}

	.article_title {
		font-size: 25rpx;
		display: flex;
		width: 95%;
		flex-direction: row;
		justify-content: space-between;
	}

	.article_detail {
		font-size: 20rpx;
		color: #999999;
		text-align: center;
	}
</style>